<?php
error_reporting(E_ALL);
define('APP_PATH',realpath(dirname(__FILE__)));
//_p(APP_PATH);
function _p($val, $die = true)
{
     header("content-Type: text/html; charset=Utf-8");  
    $out  = "<pre style=\"background: #000; color: #ccc; font: 12px 'fixedsys'; text-align: left; width: 100%; padding: 5px\">\n";
    $out .= print_r($val, true);
    $out .= "</pre>\n";
    echo $out;
    if ($die) {
       exit();
    }

   
}
//_p(APP_PATH);
//define('APP_PATH', realpath('..'));

try {

    /**
     * Read the configuration
     */
    global $_CONFIG;
    $_CONFIG = include APP_PATH . "/config/config.php";

    /**
     * Read auto-loader
     */
    include APP_PATH . "/config/loader.php";

    /**
     * Read services
     */
    include APP_PATH . "/config/services.php";

    /**
     * Handle the request
     */
   //_p($di);
    $application = new \Phalcon\Mvc\Application($di);
    //_p($di);
//_p(  $application);
    echo $application->handle()->getContent();

} catch (\Exception $e) {
    echo $e->getMessage() . '<br>';
    echo '<pre>' . $e->getTraceAsString() . '</pre>';
}
